package com.jingdong.api.model;

import java.util.Map;
import java.util.List;

/**
 * 订单数据模型
 *
 * @author 林生
 * @version 1.0.0
 */
public class OrderData {
    
    /**
     * 海博平台订单号（18-45个字符）
     */
    private String orderId;
    
    /**
     * 交易订单来源
     */
    private Integer tradeOrderSource;
    
    /**
     * 交易订单号
     */
    private String tradeOrderId;
    
    /**
     * 配送商配送服务
     */
    private String serviceCode;
    
    /**
     * 收件人姓名
     */
    private String recipientName;
    
    /**
     * 收件人电话
     */
    private String recipientPhone;
    
    /**
     * 收件人地址
     */
    private String recipientAddress;
    
    /**
     * 收件人经度
     */
    private Double recipientLng;
    
    /**
     * 收件人纬度
     */
    private Double recipientLat;
    
    /**
     * 是否即时单（0-即时单；1-预约单）
     */
    private Integer prebook;
    
    /**
     * 物品重量（kg）
     */
    private Double totalWeight;
    
    /**
     * 发件人经度
     */
    private Double senderLng;
    
    /**
     * 发件人纬度
     */
    private Double senderLat;
    
    /**
     * 发件人姓名
     */
    private String senderName;
    
    /**
     * 发件人电话
     */
    private String senderPhone;
    
    /**
     * 发件人详细地址
     */
    private String senderAddress;
    
    /**
     * 下单姓名
     */
    private String operatorName;
    
    /**
     * 配送商id
     */
    private String carrierMerchantId;
    
    /**
     * 扩展信息
     */
    private Map<String, Object> extInfo;
    
    /**
     * 取餐流水号
     */
    private String orderSequence;
    
    /**
     * 询价返回的配送费用
     */
    private Double preDeliveryFee;
    
    /**
     * 期望送达时间
     */
    private Long expectedDeliveryTime;
    
    /**
     * 预计取货时间
     */
    private Long expectedPickupTime;
    
    /**
     * 期望送达时间左区间
     */
    private Long expectedLeftDeliveryTime;
    
    /**
     * 期望送达时间右区间
     */
    private Long expectedRightDeliveryTime;
    
    /**
     * 是否保价
     */
    private Integer insuredMark;
    
    /**
     * 货品价值
     */
    private Double totalValue;
    
    /**
     * 物品体积
     */
    private Double totalVolume;
    
    /**
     * 订单流向
     */
    private Integer riderPickMethod;
    
    /**
     * 小费金额
     */
    private Double tipFee;
    
    /**
     * 物品明细
     */
    private List<Map<String, Object>> goodsDetails;
    
    /**
     * 订单备注
     */
    private String orderRemark;
    
    /**
     * 商户备注
     */
    private String shopRemark;
    
    /**
     * 配送商门店id
     */
    private String carrierShopId;
    
    /**
     * 下单人电话
     */
    private String operatorPhone;
    
    /**
     * 汽车配送车型
     */
    private String carModelCode;
    
    /**
     * 指定骑手信息
     */
    private String riderInfo;
    
    /**
     * 商家经营品类
     */
    private String category;
    
    /**
     * Builder模式构建器
     */
    public static class Builder {
        private OrderData order = new OrderData();
        
        public Builder orderId(String orderId) {
            order.orderId = orderId;
            return this;
        }
        
        public Builder tradeOrderSource(Integer tradeOrderSource) {
            order.tradeOrderSource = tradeOrderSource;
            return this;
        }
        
        public Builder tradeOrderId(String tradeOrderId) {
            order.tradeOrderId = tradeOrderId;
            return this;
        }
        
        public Builder serviceCode(String serviceCode) {
            order.serviceCode = serviceCode;
            return this;
        }
        
        public Builder recipientName(String recipientName) {
            order.recipientName = recipientName;
            return this;
        }
        
        public Builder recipientPhone(String recipientPhone) {
            order.recipientPhone = recipientPhone;
            return this;
        }
        
        public Builder recipientAddress(String recipientAddress) {
            order.recipientAddress = recipientAddress;
            return this;
        }
        
        public Builder recipientLng(Double recipientLng) {
            order.recipientLng = recipientLng;
            return this;
        }
        
        public Builder recipientLat(Double recipientLat) {
            order.recipientLat = recipientLat;
            return this;
        }
        
        public Builder prebook(Integer prebook) {
            order.prebook = prebook;
            return this;
        }
        
        public Builder totalWeight(Double totalWeight) {
            order.totalWeight = totalWeight;
            return this;
        }
        
        public Builder senderLng(Double senderLng) {
            order.senderLng = senderLng;
            return this;
        }
        
        public Builder senderLat(Double senderLat) {
            order.senderLat = senderLat;
            return this;
        }
        
        public Builder senderName(String senderName) {
            order.senderName = senderName;
            return this;
        }
        
        public Builder senderPhone(String senderPhone) {
            order.senderPhone = senderPhone;
            return this;
        }
        
        public Builder senderAddress(String senderAddress) {
            order.senderAddress = senderAddress;
            return this;
        }
        
        public Builder operatorName(String operatorName) {
            order.operatorName = operatorName;
            return this;
        }
        
        public Builder carrierMerchantId(String carrierMerchantId) {
            order.carrierMerchantId = carrierMerchantId;
            return this;
        }
        
        public Builder extInfo(Map<String, Object> extInfo) {
            order.extInfo = extInfo;
            return this;
        }
        
        public Builder orderSequence(String orderSequence) {
            order.orderSequence = orderSequence;
            return this;
        }
        
        public Builder preDeliveryFee(Double preDeliveryFee) {
            order.preDeliveryFee = preDeliveryFee;
            return this;
        }
        
        public Builder expectedDeliveryTime(Long expectedDeliveryTime) {
            order.expectedDeliveryTime = expectedDeliveryTime;
            return this;
        }
        
        public Builder expectedPickupTime(Long expectedPickupTime) {
            order.expectedPickupTime = expectedPickupTime;
            return this;
        }
        
        public Builder expectedLeftDeliveryTime(Long expectedLeftDeliveryTime) {
            order.expectedLeftDeliveryTime = expectedLeftDeliveryTime;
            return this;
        }
        
        public Builder expectedRightDeliveryTime(Long expectedRightDeliveryTime) {
            order.expectedRightDeliveryTime = expectedRightDeliveryTime;
            return this;
        }
        
        public Builder insuredMark(Integer insuredMark) {
            order.insuredMark = insuredMark;
            return this;
        }
        
        public Builder totalValue(Double totalValue) {
            order.totalValue = totalValue;
            return this;
        }
        
        public Builder totalVolume(Double totalVolume) {
            order.totalVolume = totalVolume;
            return this;
        }
        
        public Builder riderPickMethod(Integer riderPickMethod) {
            order.riderPickMethod = riderPickMethod;
            return this;
        }
        
        public Builder tipFee(Double tipFee) {
            order.tipFee = tipFee;
            return this;
        }
        
        public Builder goodsDetails(List<Map<String, Object>> goodsDetails) {
            order.goodsDetails = goodsDetails;
            return this;
        }
        
        public Builder orderRemark(String orderRemark) {
            order.orderRemark = orderRemark;
            return this;
        }
        
        public Builder shopRemark(String shopRemark) {
            order.shopRemark = shopRemark;
            return this;
        }
        
        public Builder carrierShopId(String carrierShopId) {
            order.carrierShopId = carrierShopId;
            return this;
        }
        
        public Builder operatorPhone(String operatorPhone) {
            order.operatorPhone = operatorPhone;
            return this;
        }
        
        public Builder carModelCode(String carModelCode) {
            order.carModelCode = carModelCode;
            return this;
        }
        
        public Builder riderInfo(String riderInfo) {
            order.riderInfo = riderInfo;
            return this;
        }
        
        public Builder category(String category) {
            order.category = category;
            return this;
        }
        
        public OrderData build() {
            order.validate();
            return order;
        }
    }
    
    public static Builder builder() {
        return new Builder();
    }
    
    /**
     * 验证必填字段
     * 
     * @throws IllegalArgumentException 验证失败时抛出
     */
    public void validate() {
        if (orderId == null || orderId.trim().isEmpty()) {
            throw new IllegalArgumentException("订单号 不能为空");
        }
        
        if (recipientName == null || recipientName.trim().isEmpty()) {
            throw new IllegalArgumentException("收件人姓名 不能为空");
        }
        
        if (recipientPhone == null || recipientPhone.trim().isEmpty()) {
            throw new IllegalArgumentException("收件人电话 不能为空");
        }
        
        if (recipientAddress == null || recipientAddress.trim().isEmpty()) {
            throw new IllegalArgumentException("收件人地址 不能为空");
        }
        
        if (recipientLng == null) {
            throw new IllegalArgumentException("收件人经度 不能为空");
        }
        
        if (recipientLat == null) {
            throw new IllegalArgumentException("收件人纬度 不能为空");
        }
        
        if (totalWeight == null) {
            throw new IllegalArgumentException("物品重量 不能为空");
        }
        
        if (senderLng == null) {
            throw new IllegalArgumentException("发件人经度 不能为空");
        }
        
        if (senderLat == null) {
            throw new IllegalArgumentException("发件人纬度 不能为空");
        }
        
        if (senderName == null || senderName.trim().isEmpty()) {
            throw new IllegalArgumentException("发件人姓名 不能为空");
        }
        
        if (senderPhone == null || senderPhone.trim().isEmpty()) {
            throw new IllegalArgumentException("发件人电话 不能为空");
        }
        
        if (senderAddress == null || senderAddress.trim().isEmpty()) {
            throw new IllegalArgumentException("发件人地址 不能为空");
        }
    }
    
    // Getters and Setters
    public String getOrderId() {
        return orderId;
    }
    
    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }
    
    public Integer getTradeOrderSource() {
        return tradeOrderSource;
    }
    
    public void setTradeOrderSource(Integer tradeOrderSource) {
        this.tradeOrderSource = tradeOrderSource;
    }
    
    public String getTradeOrderId() {
        return tradeOrderId;
    }
    
    public void setTradeOrderId(String tradeOrderId) {
        this.tradeOrderId = tradeOrderId;
    }
    
    public String getServiceCode() {
        return serviceCode;
    }
    
    public void setServiceCode(String serviceCode) {
        this.serviceCode = serviceCode;
    }
    
    public String getRecipientName() {
        return recipientName;
    }
    
    public void setRecipientName(String recipientName) {
        this.recipientName = recipientName;
    }
    
    public String getRecipientPhone() {
        return recipientPhone;
    }
    
    public void setRecipientPhone(String recipientPhone) {
        this.recipientPhone = recipientPhone;
    }
    
    public String getRecipientAddress() {
        return recipientAddress;
    }
    
    public void setRecipientAddress(String recipientAddress) {
        this.recipientAddress = recipientAddress;
    }
    
    public Double getRecipientLng() {
        return recipientLng;
    }
    
    public void setRecipientLng(Double recipientLng) {
        this.recipientLng = recipientLng;
    }
    
    public Double getRecipientLat() {
        return recipientLat;
    }
    
    public void setRecipientLat(Double recipientLat) {
        this.recipientLat = recipientLat;
    }
    
    public Integer getPrebook() {
        return prebook;
    }
    
    public void setPrebook(Integer prebook) {
        this.prebook = prebook;
    }
    
    public Double getTotalWeight() {
        return totalWeight;
    }
    
    public void setTotalWeight(Double totalWeight) {
        this.totalWeight = totalWeight;
    }
    
    public Double getSenderLng() {
        return senderLng;
    }
    
    public void setSenderLng(Double senderLng) {
        this.senderLng = senderLng;
    }
    
    public Double getSenderLat() {
        return senderLat;
    }
    
    public void setSenderLat(Double senderLat) {
        this.senderLat = senderLat;
    }
    
    public String getSenderName() {
        return senderName;
    }
    
    public void setSenderName(String senderName) {
        this.senderName = senderName;
    }
    
    public String getSenderPhone() {
        return senderPhone;
    }
    
    public void setSenderPhone(String senderPhone) {
        this.senderPhone = senderPhone;
    }
    
    public String getSenderAddress() {
        return senderAddress;
    }
    
    public void setSenderAddress(String senderAddress) {
        this.senderAddress = senderAddress;
    }
    
    public String getOperatorName() {
        return operatorName;
    }
    
    public void setOperatorName(String operatorName) {
        this.operatorName = operatorName;
    }
    
    public String getCarrierMerchantId() {
        return carrierMerchantId;
    }
    
    public void setCarrierMerchantId(String carrierMerchantId) {
        this.carrierMerchantId = carrierMerchantId;
    }
    
    public Map<String, Object> getExtInfo() {
        return extInfo;
    }
    
    public void setExtInfo(Map<String, Object> extInfo) {
        this.extInfo = extInfo;
    }
    
    public String getOrderSequence() {
        return orderSequence;
    }
    
    public void setOrderSequence(String orderSequence) {
        this.orderSequence = orderSequence;
    }
    
    public Double getPreDeliveryFee() {
        return preDeliveryFee;
    }
    
    public void setPreDeliveryFee(Double preDeliveryFee) {
        this.preDeliveryFee = preDeliveryFee;
    }
    
    public Long getExpectedDeliveryTime() {
        return expectedDeliveryTime;
    }
    
    public void setExpectedDeliveryTime(Long expectedDeliveryTime) {
        this.expectedDeliveryTime = expectedDeliveryTime;
    }
    
    public Long getExpectedPickupTime() {
        return expectedPickupTime;
    }
    
    public void setExpectedPickupTime(Long expectedPickupTime) {
        this.expectedPickupTime = expectedPickupTime;
    }
    
    public Long getExpectedLeftDeliveryTime() {
        return expectedLeftDeliveryTime;
    }
    
    public void setExpectedLeftDeliveryTime(Long expectedLeftDeliveryTime) {
        this.expectedLeftDeliveryTime = expectedLeftDeliveryTime;
    }
    
    public Long getExpectedRightDeliveryTime() {
        return expectedRightDeliveryTime;
    }
    
    public void setExpectedRightDeliveryTime(Long expectedRightDeliveryTime) {
        this.expectedRightDeliveryTime = expectedRightDeliveryTime;
    }
    
    public Integer getInsuredMark() {
        return insuredMark;
    }
    
    public void setInsuredMark(Integer insuredMark) {
        this.insuredMark = insuredMark;
    }
    
    public Double getTotalValue() {
        return totalValue;
    }
    
    public void setTotalValue(Double totalValue) {
        this.totalValue = totalValue;
    }
    
    public Double getTotalVolume() {
        return totalVolume;
    }
    
    public void setTotalVolume(Double totalVolume) {
        this.totalVolume = totalVolume;
    }
    
    public Integer getRiderPickMethod() {
        return riderPickMethod;
    }
    
    public void setRiderPickMethod(Integer riderPickMethod) {
        this.riderPickMethod = riderPickMethod;
    }
    
    public Double getTipFee() {
        return tipFee;
    }
    
    public void setTipFee(Double tipFee) {
        this.tipFee = tipFee;
    }
    
    public List<Map<String, Object>> getGoodsDetails() {
        return goodsDetails;
    }
    
    public void setGoodsDetails(List<Map<String, Object>> goodsDetails) {
        this.goodsDetails = goodsDetails;
    }
    
    public String getOrderRemark() {
        return orderRemark;
    }
    
    public void setOrderRemark(String orderRemark) {
        this.orderRemark = orderRemark;
    }
    
    public String getShopRemark() {
        return shopRemark;
    }
    
    public void setShopRemark(String shopRemark) {
        this.shopRemark = shopRemark;
    }
    
    public String getCarrierShopId() {
        return carrierShopId;
    }
    
    public void setCarrierShopId(String carrierShopId) {
        this.carrierShopId = carrierShopId;
    }
    
    public String getOperatorPhone() {
        return operatorPhone;
    }
    
    public void setOperatorPhone(String operatorPhone) {
        this.operatorPhone = operatorPhone;
    }
    
    public String getCarModelCode() {
        return carModelCode;
    }
    
    public void setCarModelCode(String carModelCode) {
        this.carModelCode = carModelCode;
    }
    
    public String getRiderInfo() {
        return riderInfo;
    }
    
    public void setRiderInfo(String riderInfo) {
        this.riderInfo = riderInfo;
    }
    
    public String getCategory() {
        return category;
    }
    
    public void setCategory(String category) {
        this.category = category;
    }
}
